/**
 * 系统管理 用户管理
 */
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/userInfo/userInfo' }">首页</el-breadcrumb-item>

      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="pageparm" class="user-search">
      <el-form-item label="搜索：">
        <el-input size="small" v-model="pageparm.userMobile" placeholder="请输入关键字" @change="search"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table  :data="userListData" v-loading="loading" element-loading-text="拼命加载中"
      stripe style="width: 100%" :header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }">
      <el-table-column align="center" prop="nickname" label="昵称">
      </el-table-column>
      <el-table-column align="center" prop="showId" label="ID">
      </el-table-column>
      <el-table-column align="center" prop="avatar" label="头像">
        <template slot-scope="scope">
          <img :src="scope.row.avatar" style="width: 40px; heigth: 40px; border-radius: 20px" alt="" />
        </template>
      </el-table-column>
      <el-table-column align="center" prop="sex" label="性别">
        <template slot-scope="scope">
          <div>{{ scope.row.sex == 1 ? "男" : "女" }}</div>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="createTime" label="加入时间" width="200">
      </el-table-column>

      <el-table-column label="操作" min-width="300">
        <template slot-scope="scope">
          <el-button size="mini" @click="deleteUser(scope.row)">
            踢出</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
  </div>
</template>

<script>
import { userList } from "@/api/user";
import Pagination from "../../components/Pagination";
export default {
  data() {
    return {
      userListData: [],
      //用户数据
      userData: [],
      // 分页参数
      pageparm: {
        current: 1,
        size: 10,
        total: 10,
        keywords: ''
      },
    };
  },
  // 注册组件
  components: {
    Pagination,
  },

  /**
   * 数据发生改变
   */
  watch: {},

  /**
   * 创建完毕
   */
  created() {
    this.getdata();
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    // 获取数据方法
    getdata() {
      this.loading = true;
      userList(this.pageparm).then((res) => {
        console.log(res);
        this.userListData = res.data.data;
        this.pageparm.total = Number(res.data.total);
        this.loading = false;
      });
    },
    // 分页插件事件
    callFather(parm) {
      this.pageparm.current = parm.currentPage;
      this.pageparm.size = parm.pageSize;
      this.getdata();
    },
    //搜索事件
    search() {
      this.getdata();
    },
   
  },
};
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}

.userRole {
  width: 100%;
}
</style>

 